﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using com.nm.library.Excels;
using System.Data;
using System.ComponentModel.Composition;

namespace CsrdAPI.Export
{
    [Export(typeof(ExcelImport))]
    public class SaleQuery : ExcelImport
    {
        public override ExcelImportType Type => ExcelImportType.SALEQUERY;
        public override Dictionary<string, ImportVerify> DictFields => _dictFields;

        private static readonly Dictionary<string, ImportVerify> _dictFields = new List<ImportVerify> {
            new ImportVerify{ ColumnName="品牌",FieldName="CompanyID",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="销售日期",FieldName="Billdate",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="店铺名称",FieldName="ShopName",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="店铺编码",FieldName="ShopCode",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="类别",FieldName="KindName",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="系列",FieldName="SeriesName",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="款号",FieldName="MaterialID",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="数量",FieldName="Qty",DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="单价",FieldName="RetailPrice",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="明细让利",FieldName="PresendAmount",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="业绩金额",FieldName="Amount2",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="结算金额",FieldName="Amount",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="礼券让利分摊",FieldName="THQPresend",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="一般让利",FieldName="NormalPresend",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="会员让利",FieldName="VipPresend",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="储值卡让利分摊",FieldName="ValueCardPresend",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="赠送分摊",FieldName="MasterPresend",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="四舍五入让利分摊",FieldName="RoundAmount",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="零售金额",FieldName="RetailAmount",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="其他收入分摊",FieldName="OtherAmount",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="会员红利",FieldName="Bonus",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="其他收入让利分摊",FieldName="OtherPresend",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="真实金额",FieldName="RealAmount",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="积分抵现",FieldName="DischargeIntegralAmount",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="会员优惠券分",FieldName="VIPCouponAmount",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="商场对账扣减优惠券金额",FieldName="DecTHQMarkBalanceAmount",DataType=typeof(string),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},            
           }.ToDictionary(e => e.ColumnName, e => e);

        public override object SaveImportData(DataTable dt, Dictionary<string, object> extraInfo, int userId)
        {
            throw new NotImplementedException();
        }

        public override DataTable GetExportData(string Keys)
        {
            var handler = new SaleQueryHandler();
            return handler.ExportSaleQuery(Keys);
        }
    }
}
